package org.zanateh.wargame.game.hexagon;

import java.util.HashMap;
import java.util.Map;

public class HexagonFactory {
	
	public enum HexagonType {
		BASIC,
		TEST
	}
	
	static Map<Character, HexagonType> mCharToHexagonType = new HashMap<Character, HexagonType>(){{
	    put('A', HexagonType.BASIC);
	    put('T', HexagonType.TEST);
	}};

	
	
	public static Hexagon createHexagon(char hexType)
	{
		return createHexagon(getHexagonTypeForCode(hexType));
	}

	public static HexagonType getHexagonTypeForCode(char hexType)
	{
		if(! mCharToHexagonType.containsKey(hexType)) {
			throw new IllegalArgumentException("Unrecognized hex type '" + hexType + "'");
		}
		
		return mCharToHexagonType.get(hexType);
	}
	
	public static Hexagon createHexagon(HexagonType hexType) {
		if( hexType == HexagonType.BASIC ) {
			return new BasicHexagon();
		}
		else if( hexType == HexagonType.TEST )
		{
			return new TestHexagon();
		}
		throw new IllegalArgumentException("Unrecognized hex type '" + hexType + "'");
	}
}
